package net.sycu.guomy.ems.servlet.admin;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sycu.guomy.ems.business.LoginService;
import net.sycu.guomy.ems.business.MessageService;
import net.sycu.guomy.ems.entity.LoginBean;
import net.sycu.guomy.ems.entity.MessageBean;
import net.sycu.guomy.ems.servlet.BaseServlet;

public class AdminMainServlet extends BaseServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		List<LoginBean> logins = new LoginService().searchTop10();
		List<MessageBean> messages = new MessageService().searchTop10();

		request.setAttribute("logins", logins);
		request.setAttribute("messages", messages);
		
		this.getSession().removeAttribute("alertMessage");
		request.getRequestDispatcher("./adminMain.jsp").forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
